<template>
  <div>
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane
        v-for="v in options"
        :key="v.id"
        :label="v.name"
        :name="v.id"
      ></el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import { tbDeptQuery } from "@/api/admin/user/department-manage.js";
import Bus from "@/utils/bus.js";
export default {
  data() {
    return {
      activeName: "0",
      value: [],
      options: [],
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      tbDeptQuery({ pId: "0" }).then((res) => {
        this.options = res.data.data[0].childList.filter((v) => v.type == 1);
        this.options.unshift({
          id: "0",
          name: "全部",
        });
      });
    },
    handleClick() {
      let data = {};
      if (this.activeName == 0) {
        data = {
          deptType: 1,
          sourceUnit: "",
        };
      } else {
        data = {
          deptType: 3,
          sourceUnit: this.activeName,
        };
      }
      Bus.$emit("sendSchoolId", data);
    },
  },
};
</script>
<style scoped lang="scss">
</style>